from core.basehandler import BaseHandler
from core.support import set_cutscene
from core.room import Room
#from items.pointer import Pointer
#from items.bottlecap import BottleCap
#from items.flipflop import FlipFlop
from core.action import Action
import random

class Hallway(Room):
    ken_talk = True
    ken_distracted = "start"
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
   
        
        self.solution = random.randint(1, 3)
       
        # 1 - FlipFlop
        # 2 - BottleCap
        # 3 - LaserPointer
        # add inventory items
        #self.add_item(Pointer())

                
        # build list of actions
        self.add_action(GoNetworking)
        self.add_action(TeamRoomRetreat)
        #self.add_action(PickStuff)
        
    # return description of room.
    def get_description(self):
        return "You are walking in the hallway, and Ken Freeman starts talking to you. He locks you in an infinite conversation loop about how he wants you to 'Get out there and create value for the world,' but its hard to do that while you are stuck in a hallway. Figure out a way to distract him so you can get away"
    
    # return image of room
    def get_image(self):
        if self.ken_distracted == "bottlecap":
            return 'kenbottlecap.jpg'
        elif self.ken_distracted == "pointer":
            return 'kenpointer.jpg'
        elif self.ken_distracted == "flipflop":
            return 'kenflipflop.jpg'
        else:
            return 'kensmiles.jpg'

    
class HallwayHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Hallway
    
    # define actions for this room
    
class GoNetworking(Action):
    def __init__(self):
        Action.__init__(self, "Go Networking")    # do basic initialization for every action
    
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go Networking"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        
        if self.room.ken_talk:
            return 'hallway'
        else:
            return 'cornwalls'
        
    def do_action(self,game,room,request):
        if self.room.ken_talk:
            set_cutscene("Ken is still going on & on. You gotta wiggle out of this conversation bro !!")
        return
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

class TeamRoomRetreat(Action):
    def __init__(self):
        Action.__init__(self, "Retreat to Team Room")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Retreat to Team Room"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'team_room'
    
    def is_enabled(self):
        if self.room.ken_talk:
            return True
        else:
            return False
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
